﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using KC.DataAccess.MV6;

public partial class Tags: System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
		MV6DataContext dc = new MV6DataContext(ConfigurationManager.ConnectionStrings["MV6"].ConnectionString);

		int TagID = -1;
		if (Master.values.ContainsKey("id")) TagID = int.Parse(Master.values["id"]);
		if (TagID >= 0)
		{
			var posts = from p in dc.Posts
					  join tp in dc.TagToPosts
						on p.ID equals tp.PID
					  where tp.TID == TagID
					  orderby p.Created descending
					  select p;
			rCatDetail.DataSource = posts;
			rCatDetail.DataBind();
		}
		var tags = from t in dc.Tags
				 orderby t.Title
				 select t;
		rCats.DataSource = tags;
		rCats.DataBind();
    }
}